<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../css/general.css" rel="stylesheet" type="text/css">
	<link href="../css/main.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../js/utils.js"></script>
	<script type="text/javascript" src="../js/validator.js"></script>
	<script language="JavaScript">
	<!--
		var lower_name_empty = "渠道名称不能为空!";
		var sync_url = "渠道同步地址不能为空!";
		var price = "结算价格应为整数!";
		var code = "通道指令不能为空!";
		var price_empty = "结算价格不能为空!";
		function validate()
		{
		    var validator = new Validator('add');
		    validator.required('name', lower_name_empty);
		    validator.required('syncURL', sync_url);
		    validator.required('code', code);
		    validator.required('price', price_empty);
		    validator.isInt('price', price);
		    return validator.passed();
		}
	
	//-->
	</script>	
	<title></title>
</head>
<body>
	<h1>
		<span class="action-span"><a href="pipeList">渠道信息</a></span>
		<span class="action-span1">添加渠道 </span>
		<div style="clear:both"></div>
	</h1>
	
	<div class="main-div">
  		<form action="" method="post" name="add" onsubmit="return validate()">
  		<input name="id" type="hidden" value="${pipe.id}" />
		<table width="100%" id="general-table">
		      <tbody><tr>
		        <td class="label">所属通道：</td>
		        <td>
		          <select name="channel_id" onchange="ff()">
					<option value="0">-选择通道-</option>
					<c:forEach items="${channels}" var="channel">
						<c:if test="${channel.id == pipe.channelId}">
							<option value="${channel.id}" selected="selected">${channel.name}</option>
						</c:if>
						<c:if test="${channel.id != pipe.channelId}">
							<option value="${channel.id}">${channel.name}</option>
						</c:if>
					</c:forEach>
				  </select> <font color="red">*</font>
		        </td>
		      </tr>
		      <tr>
		        <td class="label">渠道名称：</td>
		        <td>
					<input type="text" name="name" value="${pipe.name}" size="25"> <font color="red">*</font>
		        </td>
		      </tr>
		      <tr>
		        <td class="label">通道指令：</td>
		        <td>
					<input type="text" name="cmd" value="${pipe.cmd}" size="25"> <font color="red">*</font>
		        </td>
		      </tr>
		      <tr>
		        <td class="label">合作方：</td>
		        <td>
					<select name="partner_id">
					<option value="0">无</option>
					<c:forEach items="${partners}" var="partner">
						<c:if test="${partner.id == pipe.partnerId}">
							<option value="${partner.id}" selected="selected">${partner.name}</option>
						</c:if>
						<c:if test="${partner.id != pipe.partnerId}">
							<option value="${partner.id}">${partner.name}</option>
						</c:if>
					</c:forEach>

					</select>
		        </td>
		      </tr>      
		      <tr>
		        <td class="label">渠道同步地址：</td>
		        <td>
		          <input type="text" name="sync_url" value="${pipe.syncUrl}" size="60"> <font color="red">*</font>
		        </td>
		      </tr>
		      <tr>
		        <td class="label">是否同步MO：</td>
		        <td>
		          	<select name="need_mo">
		          		<c:if test="${pipe.needMO == 1}">
		          			<option value="1" selected="selected">同步</option>
							<option value="0">不同步</option>
		          		</c:if>
		          		<c:if test="${pipe.needMO == 0}">
		          			<option value="1">同步</option>
							<option value="0" selected="selected">不同步</option>
		          		</c:if>
					</select>
				</td>
		      </tr>
		      <tr>
		        <td class="label">结算价格：</td>
		        <td>
		          <input type="text" name="price" value="${pipe.price}" size="20">分 <font color="red">*</font>
		      </td></tr>      
		      <tr>
		        <td class="label">扣量比例：</td>
		        <td>
		          <input type="text" name="deduction" value="${pipe.deduction}" size="20">
		      </td></tr>
		      <tr>
		        <td class="label">渠道状态：</td>
		        <td>
		          	<select name="status">
		          		<c:if test="${pipe.status == 1}">
		          			<option value="1" selected="selected">合作中</option>
							<option value="0">终止合作</option>
							<option value="2">测试中</option>
		          		</c:if>
		          		<c:if test="${pipe.status == 0}">
		          			<option value="1">合作中</option>
							<option value="0" selected="selected">终止合作</option>
							<option value="2">测试中</option>
		          		</c:if>
		          		<c:if test="${pipe.status == 2}">
		          			<option value="1" selected="selected">合作中</option>
							<option value="0">终止合作</option>
							<option value="2" selected="selected">测试中</option>
		          		</c:if>
					
					</select>
				</td>
		      </tr>
		      <tr>
		        <td class="label">渠道描述：</td>
		        <td><textarea rows="10" cols="50" name="desc">${pipe.description}</textarea>
		        </td>
		      </tr>
		</tbody></table>
		<div class="button-div">
        	<input type="submit" value=" 确定 ">
        	<input type="reset" value=" 重置 ">
      	</div>
		</form>
	</div>

</body>
</html>